package cdrprocessing.common.rules;

import java.io.Serializable;

public class DiscountForPopularUsersRule extends AbstractRule implements Serializable {

    private final int timeAmount;

    private final String timeUnit;

    public DiscountForPopularUsersRule(int id, int timeAmount, String timeUnit) {
        super("DiscountForPopularUsersRule", id);
        this.timeAmount = timeAmount;
        this.timeUnit = timeUnit;
    }

    public int getTimeAmount() {
        return timeAmount;
    }

    public String getTimeUnit() {
        return timeUnit;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + timeAmount;
        result = prime * result + ((timeUnit == null) ? 0 : timeUnit.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!super.equals(obj))
            return false;
        if (getClass() != obj.getClass())
            return false;
        DiscountForPopularUsersRule other = (DiscountForPopularUsersRule) obj;
        if (timeAmount != other.timeAmount)
            return false;
        if (timeUnit == null) {
            if (other.timeUnit != null)
                return false;
        } else if (!timeUnit.equals(other.timeUnit))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "DiscountForPopularUsersRule [timeAmount=" + timeAmount + ", timeUnit=" + timeUnit + "]";
    }

}
